﻿<?php
session_start();

require_once "config.php";
require_once "db.class.php";
require_once "server.class.php";

$params = array("host"=>"$host", "user"=>"$user", "pass"=>"$pass", "db"=>"$db");
$db = new Dbclass($params, false);
$server = new ServerHelperClass($db, $tables);
$userNames = array("小平", "小王", "小揭", "小佟");

for ($i = 0; $i < 100; $i++)
{
	$userName = $userNames[rand(0, 3)].$i;
	$sql = "INSERT INTO ".$tb_user_profile." (renrenId, name, finishGuide) VALUES (-1, '".$userName."', true)";
	$result = $db->query($sql);
	$sql = "select last_insert_id()";
	$result = $db->query($sql);
	$arr = $db->fetchArray($result);
	$userId = $arr['last_insert_id()'];
	for ($j = 0; $j < 10; $j++)
	{
		if ($j == 0 || $j == 1)
			$num = rand(100000, 999999);
		else if ($j == 2 || $j == 3)
			$num = rand(0, 100000);
		else
			$num = rand(0, 10);
		$basicLevel = 0;
		$strengthenLevel = 0;
		$sql = "INSERT INTO ".$tb_object_profile." (objectIndex, objectNum, ownerId, basicLevel, strengthenLevel) VALUES (".$j.", ".$num.", ".$userId.",".$basicLevel.",".$strengthenLevel.")";
		$result = $db->query($sql);
	}
	for ($j = 0; $j < 9; $j++)
	{
		if ($j != 5)
		{
			$objectIndex = 20000 + $j;
			$num = 1;
			$basicLevel = 4;
			$strengthenLevel = 4;
			$sql = "INSERT INTO ".$tb_object_profile." (objectIndex, objectNum, ownerId, basicLevel, strengthenLevel) VALUES (".$objectIndex.", ".$num.", ".$userId.",".$basicLevel.",".$strengthenLevel.")";
			$result = $db->query($sql);
		}
	}
	for ($j = 0; $j < 4; $j++)
	{
		$objectIndex = 20000 + $j;
		$num = rand(0, 3);
		$basicLevel = rand(0, 4);
		$strengthenLevel = rand(0, 4);
		$sql = "INSERT INTO ".$tb_object_profile." (objectIndex, objectNum, ownerId, basicLevel, strengthenLevel) VALUES (".$objectIndex.", ".$num.", ".$userId.",".$basicLevel.",".$strengthenLevel.")";
		$result = $db->query($sql);
	}
	$tankIndex = 10000 + rand(0, 2);
	$basicLevel = 4;
	$strengthenLevel = 4;
	$sql = "INSERT INTO ".$tb_tank_profile." (ownerId, tankIndex, basicLevel, strengthenLevel) VALUES (".$userId.", ".$tankIndex.", ".$basicLevel.", ".$strengthenLevel.")";
	$result = $db->query($sql);
	$sql = "select last_insert_id()";
	$result = $db->query($sql);
	$arr = $db->fetchArray($result);
	$tankId = $arr['last_insert_id()'];
	$sql = "update ".$tb_user_profile." set campTankId = ".$tankId." where id = ".$userId;
	$result = $db->query($sql);
	for ($j = 0; $j < 4; $j++)
	{
		$tankIndex = 10000;
		$basicLevel = 0;
		$strengthenLevel = 4;
		$sql = "INSERT INTO ".$tb_tank_profile." (ownerId, tankIndex, basicLevel, strengthenLevel) VALUES (".$userId.", ".$tankIndex.", ".$basicLevel.", ".$strengthenLevel.")";
		$result = $db->query($sql);
	}
	for ($j = 0; $j < 4; $j++)
	{
		$tankIndex = 10000 + rand(0, 2);
		$basicLevel = rand(0, 4);
		$strengthenLevel = rand(0, 4);
		$sql = "INSERT INTO ".$tb_tank_profile." (ownerId, tankIndex, basicLevel, strengthenLevel) VALUES (".$userId.", ".$tankIndex.", ".$basicLevel.", ".$strengthenLevel.")";
		$result = $db->query($sql);
	}
}
echo "Finished!";

$db->close();

?>
